#!/bin/sh

# release on Kloxo 6.1.7
# by mustafa.ramadhan@lxcenter.org

if [ "$1" == "--help" ] || [ "$1" == "-h" ] ; then
	echo
	echo " ---------------------------------------------------------------------------"
	echo "  format: sh $0 --select=<> --spare=[]"
	echo " ---------------------------------------------------------------------------"
	echo "   --select - choose default, low, medium and high"
	echo "     - default -> minspare = 2; max-spare = 4"
	echo "     - low     -> 1/4 x available memory"
	echo "     - medium  -> 1/3 x available memory"
	echo "     - high    -> 1/2 x available memory"
	echo "   --spare - spare/unused memory in MB; default: 25% total memory"
	echo
	echo " Equation: a = t - s - c"
	echo "   where: a = available, t = total, s = spare, c = used +- buffers/cache"
	echo "   - memory info taken from 'free -m' after running 'sh /script/clearcache"
	echo "   - Need reboot for OpenVZ to make accurate calculation"
	echo " * Assume: 30M (for prefork) and 35MB (for worker/event) per instance"
	echo
	exit;
fi

echo
echo "- For help, type '$0 --help'"

if [ "$#" == 0 ] ; then
	echo "- No argument supplied. Defaulting to 'medium' and 25% spare"
fi

echo

. /script/directory
lxphp.exe ../bin/fix/apache-optimize.php $*